package cn.iocoder.devlop.module.annual.report.alterstockinfo.controller.app;

import cn.iocoder.devlop.framework.common.pojo.CommonResult;
import cn.iocoder.devlop.module.annual.report.alterstockinfo.controller.vo.AlterstockinfoOverwriteVO;
import cn.iocoder.devlop.module.annual.report.alterstockinfo.controller.vo.AlterstockinfoRespVO;
import cn.iocoder.devlop.module.annual.report.alterstockinfo.convert.AlterstockinfoConvert;
import cn.iocoder.devlop.module.annual.report.alterstockinfo.dal.dataobject.AlterstockinfoDO;
import cn.iocoder.devlop.module.annual.report.alterstockinfo.service.AlterstockinfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.devlop.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 年报股权变更信息")
@RestController
@RequestMapping("/annual/report/alterstockinfo")
@Validated
public class AppAlterstockinfoController {

    @Resource
    private AlterstockinfoService alterstockinfoService;

    @GetMapping("/list")
    @PermitAll
    @Operation(summary = "获得年报股权变更信息列表")
    public CommonResult<List<AlterstockinfoRespVO>> getAlterstockinfoList(@RequestParam("regno") String regno, @RequestParam("ancheyear") String ancheyear) {
        List<AlterstockinfoDO> list = alterstockinfoService.getAlterstockinfoList(regno, ancheyear);
        return success(AlterstockinfoConvert.INSTANCE.convertList(list));
    }

    @PutMapping("/overwrite")
    @Operation(summary = "覆盖更新年报股权变更信息列表")
    public CommonResult<Boolean> overwriteAlterstockinfo(@Valid @RequestBody AlterstockinfoOverwriteVO updateReqVO) {
        alterstockinfoService.overwriteAlterstockinfo(updateReqVO);
        return success(true);
    }

}
